<template>
	<div>
		<HomeHeader></HomeHeader>
		<HomeLeft :cur="1"></HomeLeft>
		<div id="main">
			<div id="web_con" v-if="isedit">
				<div class="web_wp">
					<div class="web_location">
						<div class="here_area">
							<strong>当前位置：</strong>商户管理&nbsp;&nbsp;»&nbsp;&nbsp;商户会员&nbsp;&nbsp;»&nbsp;&nbsp;详情
						</div>
						<div class="here_btn">
							<a href="javascript:history.back()" class="web_btn btn_add"><em
									class="iconfont icon-shdcfanhui"></em>返回</a>
						</div>
					</div>

					<div class="tabTitle">
						<ul class="clearfix">
							<li class="cur"><a href="javascript:;">基本信息</a></li>
						</ul>
						<div class="tabCont">
							<div class="cont">
								<table class="dataTable">
									<tr>
										<td class="ltd">会员名称</td>
										<td class="rtd">
											<input type="text" class="input-text">
										</td>
									</tr>									
									
									<tr>
										<td class="ltd">当前累计收益</td>
										<td class="rtd">
											<input type="text" class="input-text">
										</td>
									</tr>
									<tr>
										<td class="ltd">当前存入金额</td>
										<td class="rtd">
											<input type="text" class="input-text">
										</td>
									</tr>
									<tr>
										<td class="ltd">预计年化收益</td>
										<td class="rtd">
											<input type="text" class="input-text">
										</td>
									</tr>
									
								</table>
							</div>
							
							<div class="web_table">
								<table>
									<tr>
										<!-- <th class="tac" style="width: 60px;">选择</th> -->
										<th class="tac">存入金额</th>
										<th class="tac">预计年化收益</th>
										<th class="tac">生效日期</th>
										<th class="tac">结束时间</th>
										<th class="tac">状态</th>
									</tr>
									<tr>
										<td class="tac">2000</td>
										<td class="tac">30</td>
										<td class="tac">2024-05-27</td>
										<td class="tac">2028-05-27</td>
										<td class="tac"><span style="color:#f2911e;">进行中</span></td>
										
									</tr>
									<tr>
										<td class="tac">2000</td>
										<td class="tac">30</td>
										<td class="tac">2024-05-27</td>
										<td class="tac">2028-05-27</td>
										<td class="tac"><span style="color: #27d111;">商户收益</span></td>
										
									</tr>
								</table>
							</div>
							
							
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
</template>

<script>
	import HomeHeader from '../components/Header.vue';
	import HomeLeft from '../components/Left.vue';
	import PicUp from '../components/PicUp.vue'
	export default {
		components: {
			HomeHeader,
			HomeLeft,PicUp
		},
		data() {
			return {
				info: [],
				isedit: false,
				id: 0,
				icon: '', //logo
			}
		},
		onLoad(e) {
			let that = this;
			var token = '222222222222'
			that.picheaders = {
				'X-Requested-With': 'XMLHttpRequest',
				'Authorization': 'Bearer ' + token,
			}
			
			that.isedit = true;
			// if (e.id) {
			// 	that.GetDeta(e.id);
			// }
		},
		methods: {
			
			PicIcon: function(str) {
				this.icon = str;
			},
			
			UpSuccess: function(e, file, fileList) {
				var that = this;
				console.log(file);
				var _arr = {
					name: file.name,
					url: '//' + file.response.fullurl,
				}
				that.piclist = that.piclist.concat(_arr);
				console.log(that.piclist);
			},
			handleRemove(file, fileList) {
				var that = this;
				that.piclist = fileList;
				console.log(that.piclist);
			},
			
			
			// 详情
			GetDeta: function(id) {
				let that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				that.common.http('POST', 'members/' + id + '/edit', '', function(res) {
					uni.hideLoading();
					console.log(res.data)
					that.info = res.data;

					that.isedit = true;
				});
			},

			//保存
			SubMit: function() {
				let that = this;
				if (that.name == '') {
					uni.showToast({
						icon: 'none',
						title: '请输入名称',
						duration: 2000
					});
				} else if (that.sort == '') {
					uni.showToast({
						icon: 'none',
						title: '请输入排序',
						duration: 2000
					});
				} else {
					let _data = {
						name: that.name,
						sort: that.sort
					}
					if (that.id > 0) {
						that.common.http('POST', 'addr/' + that.id + '/update', _data, function(res) {
							uni.hideLoading();
							uni.showToast({
								icon: 'none',
								title: '修改成功！',
								duration: 2000
							});
							setTimeout(function() {
								that.navigateBack();
							}, 1500);
						});
					} else {
						that.common.http('POST', 'addr/store', _data, function(res) {
							uni.hideLoading();
							uni.showToast({
								icon: 'none',
								title: '添加成功',
								duration: 2000
							});
							setTimeout(function() {
								that.navigateBack();
							}, 1500);
						});
					}
				}
			},

			navigateBack() {
				// #ifdef H5
				const pages = getCurrentPages()
				if (pages.length > 1) {
					uni.navigateBack(1)
					return;
				}
				//使用vue-router返回上一级
				let a = this.$router.go(-1)
				if (a == undefined) {}
				return;
				// #endif
				uni.navigateBack();
			},

		}
	}
</script>

<style>


</style>